/*
 * (C) Copyright 2012 Compal Electronics, Inc. 
 *
 * This software is the property of Compal Electronics, Inc.
 * You have to accept the terms in the license file before use.
 *
 */

#ifndef OPENCVFACIALDETECTORBASE_H
#define OPENCVFACIALDETECTORBASE_H

using namespace std;
#include <string>
#include <fstream>
#include <opencv2/opencv.hpp>
#include "BaseData.h"
using namespace cv;

#define CVSAVEIMAGE(path, img) do{cvSaveImage((path), (img)); cdebug("%s saved to %s\n", #img, (path));} while(0)

namespace facial_compal {

class OpenCVFacialDetectorBase{
    public:
        OpenCVFacialDetectorBase(const char *haarAbsoluteDirectory);
        ~OpenCVFacialDetectorBase();
        CvSeq *facial_detect(IplImage *image, const FaceFeature ff, CvMemStorage *memStorage);
        //for opencv2.4.2 above ++++++++
        vector<cv::Rect> &facial_detect(const cv::Mat& image, vector<cv::Rect>& objects, const FaceFeature ff);
        //for opencv2.4.2 above --------
        void skinFilterByYCbCr(IplImage *img, IplImage *mask);
		int getSmileDegree();
    private:
        CvSize optimal_size(CvSize orig);
        IplImage *scale_gray_image(const IplImage * srcImg);
        CvRect *get_roi_rect4ff(CvRect * faceRect, CvRect * dstRect, FaceFeature ff);
        CvSeq *removeDuplicate(CvSeq *input_seq);

        std::string                             sCascadeFiles[FACE_NONE];	//haar detect cascade files
		static CvHaarClassifierCascade          *haarCascadeClassifiers[FACE_NONE];	//loaded haarclassifier
        static bool                             isHaarLoaded;           //wheather haar casclassifer file loaded

		const std::string CASCADE_FILE_DIRBASE;
		int iSmileDegree;
};

}


#endif //OPENCVFACIALDETECTORBASE_H
